// function getData<T>(value:T):T{
//     return value
// }

// getData<number>('hello')

function swap<T,U>(tuple:[T,U]):[U,T]{
    return [tuple[1],tuple[0]]
}

console.log(swap<number,string>([5,'hello']))


function minFun<T>(arr:T[]):T{
    let minNum = arr[0];

    for(let i = 0;i<arr.length;i++){
        if(minNum > arr[i]){
            minNum = arr[i]
        }
    }
    return minNum
}

console.log(minFun<number>([1,2,0,4]))

console.log(minFun<string>(['a','d','c']))


class MinClass<T>{
    list:T[];
    constructor(){
        this.list = [];
    }

    add(ele:T){
        this.list.push(ele)
    }

    getMinNum():T{
        let minNum = this.list[0];

        for(let i = 0;i<this.list.length;i++){
            if(minNum > this.list[i]){
                minNum = this.list[i]
            }
        }
        return minNum
    }
}


let minNum1 = new MinClass<string>();

minNum1.add('b');
minNum1.add('o');


console.log(minNum1.getMinNum());

let minNum2 = new MinClass<number>();

minNum2.add(1);
minNum2.add(2);


console.log(minNum2.getMinNum());
